/**
 * Project litesql++
 */


#include <map>
#include "sqlite_record.h"
#include "log.h"

using std::make_pair;

/**
 * SQLiteRecord implementation
 */

SQLiteRecord::SQLiteRecord() { }

SQLiteRecord::~SQLiteRecord() { }

void SQLiteRecord::SetColumnValue(const string& key, const string& value) {
    if (key.size()) {
        fields_.insert(make_pair(key, value));
    } else {
        LOGE("%s", "Column name is NULL");
    }
}

/**
 * @param column_name
 * @return const bool
 */
const bool SQLiteRecord::GetBool(const string& column_name) {
    return std::stoi(fields_[column_name]);
}

/**
 * @param column_name
 * @return const int32_t
 */
const int32_t SQLiteRecord::GetInt32(const string& column_name) {
    return std::stoi(fields_[column_name]);
}

/**
 * @param column_name
 * @return const int64_t
 */
const int64_t SQLiteRecord::GetInt64(const string& column_name) {
    return std::stoll(fields_[column_name]);
}

/**
 * @param column_name
 * @return const double
 */
const double SQLiteRecord::GetDouble(const string& column_name) {
    return std::stod(fields_[column_name]);
}

/**
 * @param column_name
 * @return const string
 */
const string SQLiteRecord::GetText(const string& column_name) {
    return fields_[column_name];
}

/**
 * @return const int
 */
const int SQLiteRecord::ColumnsCount() {
    return fields_.size();
}






